package com.ikingtech.framework.sdk.organization.api;

import com.ikingtech.framework.sdk.base.model.DragOrderParam;
import com.ikingtech.framework.sdk.core.response.R;
import com.ikingtech.framework.sdk.organization.model.OrganizationDTO;
import com.ikingtech.framework.sdk.organization.model.OrganizationQueryParamDTO;
import com.ikingtech.framework.sdk.organization.model.OrganizationUserDTO;
import com.ikingtech.framework.sdk.web.annotation.PostRequest;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * @author tie yan
 */
public interface OrganizationApi {

    /**
     * Add a new organization.
     * @param organization The organization information to be added.
     * @return The response object containing the organization's generated ID.
     */
    @PostRequest(order = 1, value = "/add", summary = "新增", description = "新增，新增成功后返回编号。")
    R<String> add(@Parameter(name = "organization", description = "组织信息")
                  @Validated @RequestBody OrganizationDTO organization);

    /**
     * Deletes an organization.
     *
     * @param id The ID of the organization to be deleted.
     * @return The result of the delete operation.
     */
    @PostRequest(order = 2, value = "/delete", summary = "删除", description = "删除。")
    R<Object> delete(@Parameter(name = "id", description = "编号")
                     @RequestBody String id);

    /**
     * Updates an organization.
     *
     * @param dept The organization information to be updated.
     * @return The result of the update operation.
     */
    @PostRequest(order = 3, value = "/update", summary = "更新", description = "更新。")
    R<Object> update(@Parameter(name = "dept", description = "组织信息")
                     @Validated @RequestBody OrganizationDTO dept);

    /**
     * Retrieves organizations using pagination.
     *
     * @param queryParam The query parameters for pagination.
     * @return The list of organizations based on the query parameters.
     */
    @PostRequest(order = 4, value = "/list/page", summary = "分页查询", description = "分页查询，没有查询结果时返回空列表。")
    R<List<OrganizationDTO>> page(@Parameter(name = "queryParam", description = "查询条件")
                                  @RequestBody OrganizationQueryParamDTO queryParam);

    /**
     * Retrieves all organizations.
     *
     * @return The list of all organizations.
     */
    @PostRequest(order = 5, value = "/list/all", summary = "全量查询", description = "全量查询，没有查询结果时返回空列表。")
    R<List<OrganizationDTO>> all();

    /**
     * Retrieves the details of an organization.
     *
     * @param id The ID of the organization.
     * @return The details of the organization.
     */
    @PostRequest(order = 7, value = "/detail/id", summary = "查询详情", description = "查询详情，数据不存在时仍然返回成功,数据为null。")
    R<OrganizationDTO> detail(@Parameter(name = "id", description = "编号")
                              @RequestBody(required = false) String id);

    /**
     * Performs drag and drop sorting of organizations.
     *
     * @param dragParam The drag and drop parameters.
     * @return The result of the drag and drop operation.
     */
    @PostRequest(order = 8, value = "/drag", summary = "拖拽排序", description = "拖拽排序，调用拖拽排序接口后需再次调用列表查询接口展示最新排序结果。")
    R<Object> drag(@Parameter(name = "dragParam", required = true, description = "拖拽参数。")
                   @RequestBody DragOrderParam dragParam);

    /**
     * Enables an organization.
     *
     * @param id The ID of the organization to be enabled.
     * @return The result of the enable operation.
     */
    @PostRequest(order = 9, value = "/enable", summary = "启用", description = "停用")
    R<Object> enable(@Parameter(name = "id", required = true, description = "编号")
                     @RequestBody String id);

    /**
     * Disables an organization.
     *
     * @param id The ID of the organization to be disabled.
     * @return The result of the disable operation.
     */
    @PostRequest(order = 9, value = "/disable", summary = "停用", description = "停用")
    R<Object> disable(@Parameter(name = "id", required = true, description = "编号")
                      @RequestBody String id);

    /**
     * Retrieves the paginated list of users under an organization.
     *
     * @param queryParam The query parameters for pagination.
     * @return The paginated list of users under the organization.
     */
    @PostRequest(order = 11, value = "/user/list/page", summary = "查询组织下所有的用户分页", description = "查询组织下所有的用户分页")
    R<List<OrganizationUserDTO>> pageUserById(@Parameter(name = "page", required = true, description = "编号")
                                              @RequestBody OrganizationQueryParamDTO queryParam);

    /**
     * Retrieves all sub-organizations under an organization.
     *
     * @param queryParam The query parameters for retrieving sub-organizations.
     * @return The list of all sub-organizations.
     */
    @PostRequest(order = 12, value = "/sub/all/list", summary = "查询组织下所有的用户分页", description = "查询组织下所有的用户分页")
    R<List<OrganizationDTO>> listSubAll(@Parameter(name = "queryParam", required = true, description = "查询条件")
                                        @RequestBody OrganizationQueryParamDTO queryParam);
}
